﻿using Gargoyle.Roton;
using System;
using System.Collections.Generic;
using System.Text;

namespace Gargoyle.ZZT
{
    class MessageConverter
    {
        protected Parameters Parameters;

        public MessageConverter(Parameters newParameters)
        {
            Parameters = newParameters;
        }

        public ByteString Convert(ByteString message, int value)
        {
            List<byte> result = new List<byte>();
            for (int i = 0; i < message.Length; i++)
            {
                switch (message[i])
                {
                    case 0x24: //$, color
                        result.AddRange((byte[])Parameters.Colors[value & 0x07]);
                        break;
                    case 0x25: //%, raw value
                        result.AddRange((byte[])new ByteString(value.ToString()));
                        break;
                    default:
                        result.Add(message[i]);
                        break;
                }
            }
            return result.ToArray();
        }
    }
}
